package org.cuijq.thinking.in.spring.bean.definition;

import org.cuijq.thinking.in.spring.bean.factory.DefaultFactory;
import org.cuijq.thinking.in.spring.bean.factory.UserFactory;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class SingletonBeanRegisterBean {
    public static void main(String[] args) {
        AnnotationConfigApplicationContext ac = new AnnotationConfigApplicationContext();
        UserFactory userFactory = new DefaultFactory();
        ConfigurableListableBeanFactory beanFactory = ac.getBeanFactory();
        beanFactory.registerSingleton("userFactory",userFactory);
        ac.refresh();

        UserFactory userFactory1 = beanFactory.getBean("userFactory",UserFactory.class);
        System.out.println("xxxxxxxxx:"+(userFactory==userFactory1));

        ac.close();
    }
}
